package com.xp.interview.dao;

import com.xp.interview.model.NoteModel;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;

import java.util.List;

/**
 * Created by xp on 15/10/14.
 */

//search:
// db.notes.find({
// $or:[
//      {content:/key/},
//      {title:/key/}
//      ]
// })
public interface NoteModelRepository extends MongoRepository<NoteModel,ObjectId>{
    @Query("{$or:[{content:{$regex:?0,$options:'i'}},{title:{$regex:?0,$options:'i'}}]}")
    public List<NoteModel> findByTitleAndContentLike(String key);
}
